from rest_framework.viewsets import ModelViewSet
from meiduo_mall_admin.my_paginate import MyPageNumberPagination
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from . import channel_serializers
from rest_framework.generics import ListAPIView


# 频道页面获取
class CategoriesViews(ModelViewSet):
    pagination_class = MyPageNumberPagination
    serializer_class = channel_serializers.CategoriesSerializer
    queryset = GoodsChannel.objects.all()


# 新增频道 频道组获取
class GoodsChannelGroupViews(ListAPIView):
    serializer_class = channel_serializers.GoodsChannelGroupSerializer
    queryset = GoodsChannelGroup.objects.all()


# 新增频道 一级分类获取
class GoodsChannelCategoryViews(ListAPIView):
    serializer_class = channel_serializers.GoodsChannelCategorySerializer
    queryset = GoodsCategory.objects.filter(parent_id=None).all()
